var express = require('express');
var app = express();


// 可以通过相对的路径去访问到文件下面的资源
// 如：http://localhost:8081/assert/images/coffeedog.jpg
app.use('/assert', express.static('assert'));

app.get('/', function (req, res) {
    res.writeHead(200,{'Content-Type':'text/html;charset=utf-8'});//设置response编码为utf-8
    // res.location({"Content-Type": "text/plain ;charset=utf-8"});
    a = '<a href="http://localhost:8081/assert/images/coffeedog.jpg">点击查看</a>';
    //res.send('去查看资源文件吧');
    res.write(a);
    res.write('<p>some html</p>');
})

var server = app.listen(8081, function () {

    var host = server.address().address
    var port = server.address().port

    console.log("应用实例，访问地址为 http://%s:%s", host, port)

})